#include<bits/stdc++.h>
#define sd(n) scanf("%d",&n) 
#define sld(n) scanf("%lld",&n)
#define pd(n) printf("%d", (n))
#define pld(n) printf("%lld", n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
const int N=2e5;
#define INF 0x7fffffff
typedef long long int ll;
using namespace std;
//----------------------------------------------------------------------------//

void solve()
{
	string s;cin>>s;
	int n=s.size();
	string t;
	for(int i=1;i<s.size()-1;i++)
	{
		t.push_back(s[i-1]);
		if(s[i]=='a')
		{
			cout<<t<<" a "<<s.substr(i+1,n-i-1)<<'\n';
			return;
		}
	}
	cout<<s[0]<<" "<<s.substr(1,n-2)<<" "<<s[n-1]<<'\n';
}

int main()
{
	int T;
	sd(T);
	while (T--)
	{
		solve();
	}
	return 0;
}